import request from '@/utils/http'

interface BaseResponse<T = any> {
  code: string
  msg: string
  data: T
}

export function getWebsiteSystem(params: object) {
  return request.get<BaseResponse>({
    url: 'ds-config/get',
    params
  })
}

export function getAddressInfo() {
  return request.get<BaseResponse>({
    url: `ds-region/get`
  })
}

export function addDrivingSchool(data: object) {
  return request.post<BaseResponse>({
    url: '/ds-store',
    data
  })
}

export function getThaliData() {
  return request.get<BaseResponse>({
    url: '/ds-thali/options'
  })
}

export function editUserInfo(data: object) {
  return request.put<BaseResponse>({
    url: '/users/profile',
    data
  })
}

export function editPassword(data: object) {
  return request.put<BaseResponse>({
    url: '/users/password',
    data
  })
}

export function getCustomerInfo(id: string) {
  return request.get<BaseResponse>({
    url: `/ds-customer/user/${id}`,
    requestOptions: { errorMessageMode: 'modal' }
  })
}

export function getAddStatus() {
  return request.get<BaseResponse>({
    url: '/users/getAddStatus'
  })
}

export function editDrivingSchoolInfo(data: object, id: string) {
  return request.put<BaseResponse>({
    url: `/ds-store/${id}`,
    data
  })
}

export function deleteDrivingSchool(id: string) {
  return request.del<BaseResponse>({
    url: `/ds-store/${id}`
  })
}

export function getSystemSetting(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-config/get',
    params
  })
}

// 登录信息记录
export function loginLogs() {
  return request.get<BaseResponse>({
    url: 'logs'
  })
}

export function getAuthQr() {
  return request.get<BaseResponse>({
    url: '/wechat/authQr'
  })
}
export function getAppletAuthQr() {
  return request.get<BaseResponse>({
    url: '/wechat/appletAuthQr'
  })
}

export function getWXAuthorizerInfo(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getAuthorizer',
    params
  })
}

// 获取公众号信息
export function getGZHAuthorizerInfo(params: object) {
  return request.get<BaseResponse>({
    url: '/wp/get',
    params
  })
}

export function getWeAppAuditStatus(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getAuditStat',
    params
  })
}

export function weAppUpdate(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/verup',
    params
  })
}

export function weAppAudit(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/submitAudit',
    params
  })
}

export function getWeAppTrialQRCode(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getTrialQRCode',
    params
  })
}

export function delBindWeapp(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/delBind',
    params
  })
}
export function delBindGZH(params: object) {
  return request.get<BaseResponse>({
    url: '/wp/delBind',
    params
  })
}

export function undoWeappAudit(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/undoAudit',
    params
  })
}

export function getPayConfig(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getPayConfig',
    params
  })
}

export function updatePayConfig(data: object) {
  return request.post<BaseResponse>({
    url: '/wechat/updatePayConfig',
    data
  })
}

export function getV3Key(num: number) {
  return request.get<BaseResponse>({
    url: `/wechat/getV3Key/${num}`
  })
}

export function getTesterList(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getTester',
    params
  })
}

export function bindTester(data: object) {
  return request.post<BaseResponse>({
    url: '/wechat/bindTester',
    data
  })
}

export function unbindTester(data: object) {
  return request.post<BaseResponse>({
    url: '/wechat/unbindTester',
    data
  })
}

export function getPrivacySetting(params: object) {
  return request.get<BaseResponse>({
    url: '/wechat/getprivacysetting',
    params
  })
}

export function setPrivacySetting(data: object) {
  return request.post<BaseResponse>({
    url: '/wechat/setprivacysetting',
    data
  })
}

export function getThaliList(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-thali/page',
    params
  })
}

export function getQrCode(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-driving-school/getQrCode',
    params
  })
}

export function getPaymentStatus(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-driving-school/payStatusConfirm',
    params
  })
}

export function completelyDeleteDrivingSchool(id: string) {
  return request.del<BaseResponse>({
    url: `/ds-store/${id}/del`
  })
}

export function restoreDrivingSchool(id: string) {
  return request.get<BaseResponse>({
    url: `/ds-store/${id}/restore`
  })
}

export function orderRefund(data: object) {
  return request.post<BaseResponse>({
    url: '/dsOrders/refund',
    data
  })
}

export function thaliRenewal(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-driving-school/renewal',
    params
  })
}
export function editConfigure(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `wp/updateAppSecret/${id}`,
    data
  })
}
export function uploadTestFile(data: object) {
  return request.post<BaseResponse>({
    url: `wp/uploadVerificationFile`,
    data
  })
}

export function getQiniuToken(params: object) {
  return request.get<BaseResponse>({
    url: '/files/qiniu/token',
    params
  })
}

export function smsSetting(data: object) {
  return request.post<BaseResponse>({
    url: '/smsSetting/page',
    data
  })
}

export function updateSmsSetting(data: object) {
  return request.put<BaseResponse>({
    url: '/smsSetting/update',
    data
  })
}

export function testSend(params: object) {
  return request.get<BaseResponse>({
    url: '/smsSetting/testSend',
    params
  })
}
